/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.hk.shop.service.shop;

import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.service.CrudService;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.thinkgem.jeesite.modules.hk.shop.dao.order.HkShopUserOrderDao;
import com.thinkgem.jeesite.modules.hk.shop.dao.order.HkShopUserOrderDetailDao;
import com.thinkgem.jeesite.modules.hk.shop.dao.shop.HkShopUserOrderWithdrawDao;
import com.thinkgem.jeesite.modules.hk.shop.entity.order.HkShopUserOrder;
import com.thinkgem.jeesite.modules.hk.shop.entity.order.HkShopUserOrderDetail;
import com.thinkgem.jeesite.modules.hk.shop.entity.shop.HkShopUserOrderWithdraw;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 用户订单管理Service
 *
 * @author 罗天文
 * @version 2018-08-22
 */
@Service
@Transactional(readOnly = true)
public class HkShopUserOrderWithrawService extends CrudService<HkShopUserOrderWithdrawDao, HkShopUserOrderWithdraw> {

    @Autowired
    private HkShopUserOrderDetailDao hkShopUserOrderDetailDao;

    public HkShopUserOrderWithdraw get(String id) {
        HkShopUserOrderWithdraw hkShopUserOrderWithdraw = super.get(id);
        hkShopUserOrderWithdraw.setHkShopUserOrderDetailList(hkShopUserOrderDetailDao.findList(new HkShopUserOrderDetail(hkShopUserOrderWithdraw)));
        return hkShopUserOrderWithdraw;
    }

    public List<HkShopUserOrderWithdraw> findList(HkShopUserOrderWithdraw hkShopUserOrderWithdraw) {
        return super.findList(hkShopUserOrderWithdraw);
    }

    public Page<HkShopUserOrderWithdraw> findPage(Page<HkShopUserOrderWithdraw> page, HkShopUserOrderWithdraw hkShopUserOrderWithdraw) {



        return super.findPage(page, hkShopUserOrderWithdraw);
    }


    @Transactional(readOnly = false)
    public void delete(HkShopUserOrderWithdraw hkShopUserOrderWithdraw) {
        super.delete(hkShopUserOrderWithdraw);
        hkShopUserOrderDetailDao.delete(new HkShopUserOrderDetail(hkShopUserOrderWithdraw));
    }


    public Page<HkShopUserOrderWithdraw> findCoupon(Page<HkShopUserOrderWithdraw> page, HkShopUserOrderWithdraw hkShopUserOrderWithdraw) {
        // 生成数据权限过滤条件（dsf为dataScopeFilter的简写，在xml中使用 ${sqlMap.dsf}调用权限SQL）
        hkShopUserOrderWithdraw.getSqlMap().put("dsf", dataScopeFilter(hkShopUserOrderWithdraw.getCurrentUser(), "o", "a"));
        // 设置分页参数
        hkShopUserOrderWithdraw.setPage(page);
        // 执行分页查询
        page.setList(dao.findList(hkShopUserOrderWithdraw));
        return page;
    }

    @Transactional(readOnly = false)
    public void updateWithrawByOrderNumber(String orderNumber) {
        dao.updateWithrawByOrderNumber(orderNumber);
    }


}